<template>
  <PullRefresh @refresh="updateMessageList">
    <div slot="pullRefreshSlot">
      <div class="messagemain">
        <NewMessageList :items="messageList.newMessageList"></NewMessageList>
        <CurrentWeekMessageList
          :items="messageList.currentWeekMessageList"
        ></CurrentWeekMessageList>
        <CurrentMonthMessageList
          :items="messageList.currentMountMessageList"
        ></CurrentMonthMessageList>
        <MoreMessageList :items="messageList.moreMessageList"></MoreMessageList>
        <div class="messagemain_recommend">
          <h1 class="messagemain_recommendheader">{{ $t("lang.为你推荐") }}</h1>
          <ItemPanelHeader
            :item="item"
            v-for="(item, index) in messageList.recommendUsers"
            :key="'recommendUser_' + index"
          >
            <FollowButton
              :item="item"
              slot="itemPanelHeaderMenu"
              slot-scope="{ item }"
            ></FollowButton>
          </ItemPanelHeader>
          <router-link
            :to="{
              name: 'ALLRECOMMENDUSERS',
              params: { usid: $store.state.user.userId },
            }"
            class="messagemain_recommend_all_recommendusers"
            >{{ $t("lang.查看全部推荐") }}</router-link
          >
        </div>
      </div>
    </div>
  </PullRefresh>
  <!-- <van-pull-refresh
    v-model="isLoading"
    @refresh="onRefresh"
    :pulling-text="this.$t('lang.下拉即可刷新')"
    :loosing-text="this.$t('lang.释放即可刷新')"
    :loading-text="this.$t('lang.加载中')"
  >
    <div class="messagemain">
      <NewMessageList :items="messageList.newMessageList"></NewMessageList>
      <CurrentWeekMessageList
        :items="messageList.currentWeekMessageList"
      ></CurrentWeekMessageList>
      <CurrentMonthMessageList
        :items="messageList.currentMountMessageList"
      ></CurrentMonthMessageList>
      <MoreMessageList :items="messageList.moreMessageList"></MoreMessageList>
      <div class="messagemain_recommend">
        <h1 class="messagemain_recommendheader">{{ $t("lang.为你推荐") }}</h1>
        <ItemPanelHeader
          :item="item"
          v-for="(item, index) in messageList.recommendUsers"
          :key="'recommendUser_' + index"
        >
          <FollowButton
            :item="item"
            slot="itemPanelHeaderMenu"
            slot-scope="{ item }"
          ></FollowButton>
        </ItemPanelHeader>
        <router-link
          :to="{
            name: 'ALLRECOMMENDUSERS',
            params: { usid: $store.state.user.userId },
          }"
          class="messagemain_recommend_all_recommendusers"
          >{{ $t("lang.查看全部推荐") }}</router-link
        >
      </div>
    </div>
  </van-pull-refresh> -->
</template>
<script>
export default {
  name: "MessageMain",
  components: {
    PullRefresh: () =>
      import(
        /* webpackChunkName:"pullRefresh" */ "../../components/common/pullRefresh.vue"
      ),
    NewMessageList: () =>
      import(
        /* webpackChunkName: "newMessageList" */ "../../components/message/newMessageList"
      ),
    CurrentWeekMessageList: () =>
      import(
        /* webpackChunkName: "currentWeekMessageList" */ "../../components/message/currentWeekMessageList"
      ),
    CurrentMonthMessageList: () =>
      import(
        /* webpackChunkName: "currentMonthMessageList" */ "../../components/message/currentMonthMessageList"
      ),
    MoreMessageList: () =>
      import(
        /* webpackChunkName: "moreMessageList" */ "../../components/message/moreMessageList"
      ),
    ItemPanelHeader: () =>
      import(
        /* webpackChunkName:"itemPanelHeader" */ "../../components/common/itemPanel/itemPanelHeader.vue"
      ),
    FollowButton: () =>
      import(
        /* webpackChunkName:"followButton" */ "../../components/common/followButton.vue"
      ),
  },
  data() {
    return {
      isLoading: false,
      messageList: {
        newMessageList: [],
        currentWeekMessageList: [],
        currentMountMessageList: [],
        moreMessageList: [],
      },
    };
  },
  created() {
    this.updateMessageList(1).then(() => {});
  },
  methods: {
    updateMessageList(pageNum, callback) {
      let that = this;
      return new Promise((resolve, reject) => {
        that.messageList = {
          newMessageList: [
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "开始关注了你哦.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "赞了你的评论.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "分享了照片。",
                followTime: 1596094606575,
              },
            },
          ],
          currentWeekMessageList: [
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "开始关注了你哦.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "赞了你的评论.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "分享了照片。",
                followTime: 1596094606575,
              },
            },
          ],
          currentMountMessageList: [
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "开始关注了你哦.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "赞了你的评论.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "分享了照片。",
                followTime: 1596094606575,
              },
            },
          ],
          moreMessageList: [
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "开始关注了你哦.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "赞了你的评论.",
                followTime: 1596094606575,
              },
            },
            {
              userHead: "",
              nickName: "undefined",
              userId: "0123456",
              type: 1,
              content: {
                follower: [
                  { userHead: "", nickName: "undefined", userId: "0123456" },
                ],
                message: "分享了照片。",
                followTime: 1596094606575,
              },
            },
          ],
          recommendUsers: [
            {
              userId: "0123456",
              userHead:
                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595233833221&di=8cf8621bb5bdae4844362dfe99c54191&imgtype=0&src=http%3A%2F%2Fb.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fbd315c6034a85edf8c1758e240540923dc547553.jpg",
              nickName: "undefined",
              position: "中国",
              isNewContent: true,
            },
            {
              userId: "0123456",
              userHead:
                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595233833221&di=8cf8621bb5bdae4844362dfe99c54191&imgtype=0&src=http%3A%2F%2Fb.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fbd315c6034a85edf8c1758e240540923dc547553.jpg",
              nickName: "undefined",
              position: "中国",
              isNewContent: true,
            },
            {
              userId: "0123456",
              userHead:
                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595233833221&di=8cf8621bb5bdae4844362dfe99c54191&imgtype=0&src=http%3A%2F%2Fb.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fbd315c6034a85edf8c1758e240540923dc547553.jpg",
              nickName: "undefined",
              position: "中国",
              isNewContent: true,
            },
          ],
        };
        callback && callback();
        resolve();
      });
    },
  },
};
</script>
<style lang="less">
@base: 23.44rem;
.messagemain {
  min-height: 300 / @base;
  text-align: left;
  .messagemain_recommend {
    padding: 10 / @base;
    h1 {
      &.messagemain_recommendheader {
        font-size: 14 / @base;
        text-align: left;
        padding: 10 / @base 0;
      }
    }
    a {
      &.messagemain_recommend_all_recommendusers {
        font-size: 14 / @base;
        text-align: left;
        padding: 10 / @base 0;
        display: block;
      }
    }
  }
}
</style>
